import { reqGetGoodsInfoData } from "@/api"

const store = {
  goodsInfo: {},
}
const actions = {
  async getGoodsInfoData({ commit }, searchParams) {
    const res = await reqGetGoodsInfoData(searchParams)
    if (res.code === 200) {
      commit("SAVE_GOODS_INFO_DATA", res.data)
    }
  },
}

const mutations = {
  SAVE_GOODS_INFO_DATA(state, data) {
    state.goodsInfo = data
  },
}

const getters = {
  goodsList(state) {
    return state.goodsInfo.goodsList
  },
  trademarkList(state) {
    return state.goodsInfo ? state.goodsInfo.trademarkList : []
  },
  attrsList(state) {
    return state.goodsInfo ? state.goodsInfo.attrsList : []
  },
}

export default {
  namespaced: true,
  store,
  actions,
  mutations,
  getters,
}
